<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>清除浮动-双伪元素法</title>
    <style>
        .top {
            margin: 10px auto;
            width: 1200px;
            /* height: 300px; */
            background-color: #fff111;
        }

        .left {
            float: left;
            width: 200px;
            height: 300px;
            background-color: #11ff11;
        }

        .right {
            float: right;
            width: 950px;
            height: 300px;
            background-color: #c64359;
        }

        .bottom {
            height: 100px;
            background-color: #111fff;
        }

        /* before 解决外边距塌陷问题 */
        /*双伪元素法*/
        .clearfix::before,
        .clearfix::after{
            content:"";
            display: table;
        }

        /* after 清除浮动 */
        .clearfix::after{
            clear: both;
        }
    </style>
</head>
<body>
    <div class="top clearfix">
        <div class="left"></div>
        <div class="right"></div>
    </div>
    <div class="bottom"></div>
</body>
</html>